import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";

const routes: Array<RouteRecordRaw> = [
    {
        path: "/:pathMatch(.*)*",
        redirect: "/404",
    },
    {
        path: "/404",
        component: () => import("@/views/error/404.vue"),
        meta:{
            keepAlive:true // 需要缓存
        }
    },
    {
        path: "/",
        name: "dingDong-container",
        component: () => import("@/views/DingDongContainer.vue"),
        meta:{
            keepAlive:true // 需要缓存
        },
        children: [
            {
                path: "/",
                name: "home",
                component: () => import("@/views/Home.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/sign-in",
                name: "sign-in",
                component: () => import("@/views/SignIn.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/sign-up",
                name: "sign-up",
                component: () => import("@/views/SignUp.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/personal",
                name: "personal",
                meta: {
                    requireAuth: true,
                },
                component: () => import("@/views/personal/Personal.vue"),

            },
            {
                path: "/song-sheet",
                name: "song-sheet",
                component: () => import("@/views/song-sheet/SongSheet.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/song-sheet-detail/:id",
                name: "song-sheet-detail",
                component: () => import("@/views/song-sheet/SongSheetDetail.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/singer",
                name: "singer",
                component: () => import("@/views/singer/Singer.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/song-all",
                name: "song-all",
                component: () => import("@/views/song-all/SongAll.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/singer-detail/:id",
                name: "singer-detail",
                component: () => import("@/views/singer/SingerDetail.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/lyric/:id",
                name: "lyric",
                component: () => import("@/views/Lyric.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/search",
                name: "search",
                component: () => import("@/views/search/Search.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/personal-data",
                name: "personal-data",
                component: () => import("@/views/setting/PersonalData.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/FPassword",
                name: "FPassword",
                component: () => import("@/views/FPassword.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/loginByemail",
                name: "loginByemail",
                component: () => import("@/views/loginByemail.vue"),
                meta:{
                    keepAlive:true // 需要缓存
                }
            },
            {
                path: "/setting",
                name: "setting",
                meta: {
                    requireAuth: true,
                },
                component: () => import("@/views/setting/Setting.vue"),
                children: [
                    {
                        path: "/setting/PersonalData",
                        name: "personalData",
                        meta: {
                            requireAuth: true,
                        },
                        component: () => import("@/views/setting/PersonalData.vue"),
                    }
                ]
            },
        ],
    },
];

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});

export default router;
